"""
URL configuration for property_management project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include, re_path
from django.views.generic import TemplateView
from django.views.static import serve
from django.conf import settings
from rest_framework import permissions
from rest_framework.documentation import include_docs_urls
import os

urlpatterns = [
    path("admin/", admin.site.urls),
    # 包含property应用的URL路由
    path('api/', include('property.urls')),
    # 包含REST framework的默认路由（用于API文档等）
    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    # API文档
    path('docs/', include_docs_urls(title='小区物业管理系统API')),
    # 直接访问HTML文件
    path('', TemplateView.as_view(template_name='login.html')),
    path('login', TemplateView.as_view(template_name='login.html')),
    path('dashboard', TemplateView.as_view(template_name='dashboard.html')),
    path('community', TemplateView.as_view(template_name='community.html')),
    path('owners', TemplateView.as_view(template_name='owners.html')),
    path('maintenance', TemplateView.as_view(template_name='maintenance.html')),
    path('announcements', TemplateView.as_view(template_name='announcements.html')),
    path('settings', TemplateView.as_view(template_name='settings.html')),
    # 支持直接访问HTML文件
    re_path(r'^(?P<path>.*\.html)$', serve, {
        'document_root': os.path.join(settings.BASE_DIR),
    }),
]
